package net.asg.games.yokeltowers.models;

import net.asg.games.yokeltowers.view.YokelGameObject;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Array;

public class YokelGameObjectContainer {
	protected Rectangle bounds;
	protected Array<YokelGameObject> container;

	public YokelGameObjectContainer(float x, float y, float width, float height){
		container = new Array<YokelGameObject>();

		bounds = new Rectangle();
		bounds.x = x;
		bounds.y = y;
		bounds.width = width;
		bounds.height = height;
	}

	public void addObject(YokelGameObject object){
		container.add(object);
	}
	
	public YokelGameObject getObject(){
		YokelGameObject obj = (container.size > 0 ? container.pop() : null);
		return obj;
	}

	public void draw(SpriteBatch batch,float delta) {
		if(container.size  > 0)
			for (YokelGameObject gameObject : container){
				gameObject.draw(batch, delta);
			}		
	}

	public void drawDebug(ShapeRenderer debugRenderer){
		debugRenderer.rect(bounds.x, bounds.y, bounds.width, bounds.height);
	}
}
